<template>
  <view class="content">
    <!-- 开发 -->
    <web-view @message="onMessage" id="webviewShop" :src="src"></web-view>
	<!--  半透明蒙版   -->
	<cover-view class="mask" @click="copyLinkToClipboard()" ><cover-view class="mask-text">{{info}}</cover-view></cover-view>
  </view>
</template>

<script>
import { getUserInfo } from '@/api/api';
export default {
  data() {
    return {
      wv: null,
      src: '',
	  info:''
    }
  },
  onLoad(opition) {
    let _this = this
  },
  onReady() {
    const self = this;
    // #ifdef APP-PLUS  
    // #endif  
    this.setSrcUrl()
  },
  onShow() {

  },

  methods: {
    setSrcUrl() {
      let _this = this
		_this.copyLinkToClipboard()
		_this.src = uni.getStorageSync('webViewUrl')
      // let token = uni.getStorageSync('token')
      // console.log(token, '[]');
      // getUserInfo().then((res) => {
      //   _this.src = `https://shop.jichacha.vip/#/pages/index/index?token=${token}&id=${res.data.id}`
      //   console.log(_this.src, '[]');
      // }).catch(err => {
      //   console.log(err, '[]');
      //   uni.$u.toast('网络超时，请稍后再试');
      // })
    },
	copyLinkToClipboard() {
		let _this = this
		let link = _this.src
	  uni.setClipboardData({
	    data: _this.src,
	    success: function () {
	      // 可以添加用户提示，例如使用uni.showToast提示复制成功
	      uni.showToast({
	        title: '链接已复制，请在浏览器打开',
	        icon: 'none',
	        duration: 9000
	      });
		  setTimeout(()=>{
			  _this.info = uni.getStorageSync('webViewInfo');
		  },3000)
	    }
	  });
	},
    // 接收消息  
    onMessage(e) {
      const self = this;
      console.log('我收到了网页发来的消息', e.detail.data);
      let data = e.detail.data;
    },
  }
}
</script>

<style lang="scss" scoped>
	.content {
	  position: relative;
	  width: 100%;
	  height: 100vh; /* 或者具体的高度值 */
	}
	.mask {
	  position: absolute;
	  top: 0;
	  left: 0;
	  right: 0;
	  bottom: 0;
	  background-color: rgba(0, 0, 0, 0.9); /* 黑色半透明蒙版 */
		display: flex;
	    align-items: center;
	    justify-content: center;
	    z-index: 1000;
	}
	.mask-text {
	  color: white; /* 文字颜色为白色 */
	  font-size: 18px; /* 文字大小 */
	  text-align: center; /* 文字居中 */
	}
</style>
